from django.db import models


class Author(models.Model):
    name = models.CharField(max_length=100)
    age = models.IntegerField()
    email = models.EmailField()

    class Meta:
        db_table = "author"


class Publisher(models.Model):
    name = models.CharField(max_length=300)

    class Meta:
        db_table = "publisher"


class Book(models.Model):
    name = models.CharField(max_length=300)
    pages = models.IntegerField()
    price = models.FloatField()
    rating = models.FloatField()
    author = models.ForeignKey("Author", on_delete=models.PROTECT)
    publisher = models.ForeignKey("Publisher", on_delete=models.CASCADE)

    class Meta:
        db_table = "book"


class Order(models.Model):
    book_name = models.ForeignKey("Book", on_delete=models.CASCADE)
    price = models.FloatField()

    class Meta:
        db_table = "order"
